1 Public Class FrmCATITEMADD_2
2
3 Private Sub FrmCATITEMADD_2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
4 Me.Text = "Item"
5 End Sub
6
7 Private Sub FrmCATITEMADD_2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
8 Dim i As Integer
9 'MsgBox(Split(Me.Text, " - ")(0) & " " & Split(Me.Text, " - ")(1))
10
11 If Split(Me.Text, " - ")(1) = "Add" Then
12 txtbarcode.Text = ""
13 txtdesc.Text = ""
14 txtname.Text = ""
15 txtprice.Text = ""
16 txtreorder.Text = ""
17 End If
18 FILLComboBox("SELECT Group_ID, Group_Description FROM TBL_Group", cmbrand)
19 sqlSTR = "SELECT * FROM TBL_Group "
20 ExecuteSQLQuery(sqlSTR)
21 If sqlDT.Rows.Count > 0 Then
22 cmbrand.Text = sqlDT.Rows(0)("Group_ID") & " - " & sqlDT.Rows(0)("Group_Name")
23 End If
24 'FILLComboBox("SELECT Catg_ID, Catg_Name FROM TBL_Category_File", cmbCategory)
25 For i = 0 To cmbCategory.Items.Count - 1
26 If cmbCategory.Items.Count > 0 Then
27 If i = 0 Then
28 cmbCategory.Text = cmbCategory.Items(i)
29 End If
30 End If
31 Next
32 FILLComboBox2("SELECT ID, Description FROM TBL_Unit_Measure", cmbUnit)
33 For i = 0 To cmbUnit.Items.Count - 1
34 If cmbUnit.Items.Count > 0 Then
35 If i = 0 Then
36 cmbUnit.Text = cmbUnit.Items(i)
37 End If
38 End If
39
40 Next
41 End Sub
42
43 Private Sub cmdcancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdcancel.Click
44 Me.Close()
45 End Sub
46
47 Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
48 Dim errMsg As String
49 Dim msg As String
50
51 errMsg = "Please Complete The Following " & Chr(10) & " --------------------------- "
52 msg = errMsg
53 ' If cmbrand.Text = "" Then
54 ' MsgBox("Select Brand First", MsgBoxStyle.Exclamation, "Sales And Inventory")
55 ' Exit Sub
56 ' End If
57 If cmbCategory.Text = "" Then
58 MsgBox("Select Category First ", MsgBoxStyle.Information, "Sales and Inventory")
59 Exit Sub
60 End If
61
62
63 If txtname.Text = "" Then
64 msg = msg & Chr(10) & "Item Name : < Should not be blank >"
65 End If
66 If txtdesc.Text = "" Then
67 msg = msg & Chr(10) & "Item Description : < Should not be blank >"
68 End If
69 If Not IsNumeric(txtbarcode.Text) Then
70 msg = msg & Chr(10) & "Item Barcode : < Should be numeric >"
71 End If
72 If Not IsNumeric(txtprice.Text) Then
73 msg = msg & Chr(10) & "Item Price : < Should be numeric >"
74 End If
75
76 If Not IsNumeric(txtreorder.Text) Then
77 msg = msg & Chr(10) & "Item Reorder : < Should be numeric >"
78 End If
79 If Len(txtbarcode.Text) < 4 Then
80 msg = msg & Chr(10) & " Barcode : < Barcode minimum length should be 4 >"
81 End If
82 If msg <> errMsg Then
83 MsgBox(msg, MsgBoxStyle.Information, "Sales and Inventory")
84 Exit Sub
85 End If
86 If Len(txtbarcode.Text) > 13 Then
87 MsgBox("Barcode length should not be lower than 13 !! ", MsgBoxStyle.Exclamation, "Sales and Inventory")
88 Exit Sub
89 End If
90 'ADD
91 sqlSTR = "SELECT * FROM TBL_Category_Item_File WHERE Item_Description ='" & txtdesc.Text & "'"
92 ExecuteSQLQuery(sqlSTR)
93 If sqlDT.Rows.Count > 0 Then
94 MsgBox("Item Number Already Exist !!", MsgBoxStyle.Exclamation, "Sales and Inventory")
95 Exit Sub
96 End If
97
98 sqlSTR = "SELECT * FROM TBL_Category_Item_File WHERE Item_Barcode =" & txtbarcode.Text
99 ExecuteSQLQuery(sqlSTR)
100 If sqlDT.Rows.Count > 0 Then
101 MsgBox("Barcode already exists !!", MsgBoxStyle.Critical, "Sales and Inventory")
102 Exit Sub
103 End If
104
105
106
107 sqlSTR = "INSERT INTO tbl_Category_Item_File (Catg_ID, Item_Name, Item_Description, Item_Barcode, Item_Reorder_Point, Item_Org_Price, Unit_Measure, Item_Price) VALUES(" & Split(cmbCategory.Text, " - ")(0) & ", " _
108 & "'" & R_eplace(txtname.Text) & "', " _
109 & "'" & Replace(txtdesc.Text, "'", "") & "', " _
110 & txtbarcode.Text & ", " _
111 & txtreorder.Text & ", " _
112 & CDbl(txtprice.Text) & ", " _
113 & "'" & cmbUnit.Text & "', " _
114 & CDbl(txtprice.Text) + (CDbl(txtprice.Text) * (VAT / 100)) & ")"
115 ExecuteSQLQuery(sqlSTR)
116 'MsgBox(sqlSTR)
117 Audit_Trail(xUser_ID, TimeOfDay, "Add New Item File List")
118 MsgBox("Record Successfuly Update !", MsgBoxStyle.Information, "Sales and Inventory")
119 If MsgBox("Do you want to add other data ??", MsgBoxStyle.Information + MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
120 txtbarcode.Text = ""
121 txtdesc.Text = ""
122 txtname.Text = ""
123 txtprice.Text = ""
124 txtreorder.Text = ""
125 Else
126 FillListView(ExecuteSQLQuery("SELECT Item_ID as 'ID', Catg_ID as 'Category ID', Replace(Replace(Item_Name,'$.$',''''),'$..$',',') as 'Name', Item_Description as 'Description / Item Number', Item_Barcode as 'Barcode', Item_Reorder_Point as 'Reorder Point', Item_Price as 'Price', Unit_Measure as 'Measure' FROM TBL_Category_Item_File ORDER BY Item_Name"), FrmCatList.lstCat, 1)
127 Me.Close()
128 End If
129 End Sub
130
131 Private Sub txtreorder_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtreorder.TextChanged
132 txtreorder.Text = str_Filter(txtreorder, 48, 57, 0, 0)
133 End Sub
134
135 Private Sub txtbarcode_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtbarcode.TextChanged
136 txtbarcode.Text = str_Filter(txtbarcode, 48, 57, 0, 0)
137 End Sub
138
139 Private Sub txtprice_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtprice.TextChanged
140 txtprice.Text = str_Filter(txtprice, 48, 57, 46, 1)
141 If txtprice.Text = "0" Or txtprice.Text = "" Then txtprice.Text = "1"
142 End Sub
143
144 Private Sub cmbrand_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbrand.SelectedIndexChanged
145 FILLComboBox("SELECT Catg_ID, Catg_Name " & _
146 "FROM TBL_Category_File" & _
147 " WHERE Group_ID =" & Split(cmbrand.Text, " - ")(0), cmbCategory)
148 End Sub
149
150 Private Sub txtname_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtname.TextChanged
151 'txtItemName.Text = filter_Special_Char(str_Filter(txtItemName, 39, 122, 32, 40))
152 txtname.Text = filter_Special_Char(str_Filter(txtname, 34, 122, 32, 50))
153 End Sub
154
155 Private Sub txtdesc_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtdesc.TextChanged
156 txtdesc.Text = filter_Special_Char(str_Filter(txtdesc, 48, 122, 32, 50))
157 End Sub
158 End Class